<?php

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 * Description of admin
 *
 * @author QUYET
 */
class Admin extends Admin_Controller {
    //put your code here
    public function __construct() {
        parent::__construct();
        $this->load->model('ticket_cat_model');
    }
    function index(){
        redirect('ticket-admin');
    }
    public function create_ticket() {
        $this->_data = $this->ticket_cat_model->get_categories_combo(array('combo_name' => 'cat_id','cat_id' => (isset($_POST['cat_id'])) ? $this->input->post('cat_id') : 1));
        if (isset($_POST['btnSubmit'])) {
            if ($this->_do_validate()) {
                $expiry_date = ($this->input->post('expiry_date')) ? date('Y-m-d', strtotime($this->input->post('expiry_date'))) : NULL;
                $ticket_data = array(
                    'ticket_name' => trim($this->input->post('ticket_name')),
                    'description' => trim($this->input->post('description')),
                    'expiry_date' => $expiry_date,
                    'price' => trim($this->input->post('price')),
                    //'img_id' => $return_value,
                    'quantity' => trim($this->input->post('quantity')),
                    'cat_id' => $this->input->post('cat_id')
                );
                $ticket_id = $this->ticket_model->create_ticket($ticket_data);
                redirect('ticket-admin');
            } else {
                $this->_data['errors'] = validation_errors();
                $this->display_admin('create_ticket');
            }
        } else {
            $this->display_admin('create_ticket');
        }
    }
}

?>
